﻿#region Copyright Notice
// This file is part of GestionPedago.
// <description>
// Copyright (C) 2012 ENI Ecole Informatique
// 
// GestionPedago is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// <program> is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;
using GestionPedago.EntityContext.EntityOPTools;

namespace GestionPedago.EntityContext
{
    public partial class Stagiaire : EntityObject
    {
       /* public List<PlanningIndividuelFormation> GetListePlanningIndividuelFormation(bool orderByDateInscriptionAsc = true){
            try
            {
               
                IQueryable<PlanningIndividuelFormation> query = EntityConnection.GetContext().PlanningIndividuelFormation;
                PlanningIndividuelFormation pif = new EntityContext.PlanningIndividuelFormation();
                pif.CodeStagiaire = this.CodeStagiaire;
                query.Where(it => it.CodeStagiaire == this.CodeStagiaire);
                if (orderByDateInscriptionAsc)
                {
                    query.OrderBy(it => it.DateInscription);
                }
                else
                {
                    query.OrderByDescending(it => it.DateInscription);
                }
                query.Select(it => it);
                
                List<PlanningIndividuelFormation> lst = new List<PlanningIndividuelFormation>();

                foreach (PlanningIndividuelFormation f in query)
                {

                    lst.Add(f);
                }

                return lst;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }*/

        //public List<PlanningIndividuelDetail> GetListePlanningIndividuelDetail(PlanningIndividuelFormation pif, bool orderByDebutCoursAsc = true)
        //{
        //    try
        //    {
        //        IQueryable<PlanningIndividuelDetail> query = EntityConnection.GetContext().PlanningIndividuelDetail;
        //       /* PlanningIndividuelFormation pif = new EntityContext.PlanningIndividuelFormation();*/
        //       /* pif.CodeStagiaire = this.CodeStagiaire;*/
        //        query.Where(it => it.PlanningIndividuelFormation.CodePlanning == pif.CodePlanning);
        //        if (orderByDebutCoursAsc)
        //        {
        //            query.OrderBy(it => it.DebutCours);
        //        }
        //        else
        //        {
        //            query.OrderByDescending(it => it.DebutCours);
        //        }
        //        query.Select(it => it);

        //        List<PlanningIndividuelDetail> lst = new List<PlanningIndividuelDetail>();

        //        foreach (PlanningIndividuelDetail f in query)
        //        {

        //            lst.Add(f);
        //        }

        //        return lst;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //public List<PlanningECFDetail> GetListePlanificationECFDetailByFormation(PlanningIndividuelFormation pif = null, bool orderByDateECFAsc = true)
        //{
        //    try
        //    {
        //        IQueryable<PlanningECFDetail> query = EntityConnection.GetContext().PlanningECFDetail;
        //        query.Where(it => it.PlanningIndividuelFormation.CodePlanning ==  pif.CodePlanning);
        //        if (orderByDateECFAsc)
        //        {
        //            query.OrderBy(it => it.PlanningECF.DateECF);
        //        }
        //        else
        //        {
        //            query.OrderByDescending(it => it.PlanningECF.DateECF);
        //        }
        //        query.Select(it => it);

        //        List<PlanningECFDetail> lst = new List<PlanningECFDetail>();

        //        foreach (PlanningECFDetail f in query)
        //        {
        //            lst.Add(f);
        //        }

        //        return lst;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        public List<PlanningIndividuelDetail> GetAllPlanningIndividuelDetail()
        {
            List<PlanningIndividuelDetail> lst = new List<PlanningIndividuelDetail>();
            foreach (PlanningIndividuelFormation pif in this.PlanningIndividuelFormation)
            {
                lst.AddRange(pif.PlanningIndividuelDetail);
            }
            return lst;
        }
    }
}
